/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/zigzag-conversion
   @Language: C++
   @Datetime: 19-05-17 17:05
   */

class Solution {
public:
	string convert(string &s, int numRows) {
		vector<string> vs(numRows);
		for(int i=0; i<s.length();){
			for(int r=0; r<numRows && i<s.length(); vs[r++].push_back(s[i++]));
			for(int r=numRows-2; r>0 && i<s.length(); vs[r--].push_back(s[i++]));
		}
		string str;
		for(int i=0; i<vs.size(); str.append(vs[i++]));
		return str;
	}
};
